package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/*
Author     :Dsi
Date       : 2021/12/1 11:23
Description: 
*/
public class Demo02 {
    public static void main(String[] args){
        Connection connection = null;
        PreparedStatement preparedStatement=null;
        try{
            connection = JDBUtils.getDriver("jdbc:mysql://localhost:3307/cgb2110_04?characterEncoding=utf8", "root", "root");

            String sql="insert into dept values(null,?,?)";
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setObject(1,"ds");
            preparedStatement.setObject(2,"三区");

            int i = preparedStatement.executeUpdate();
        }catch (Exception e){
            System.out.println("登录异常");
            e.printStackTrace();
        }finally {
            JDBUtils.close(null,connection,preparedStatement);
        }
    }
}
